enum DataType { TEXT, IMAGE, VIDEO }

enum OfficialFlag { YES, NO }

///[WXMiniProgramType.RELEASE]正式版
///[WXMiniProgramType.TEST]测试版
///[WXMiniProgramType.PREVIEW]预览版
enum WXMiniProgramType { RELEASE, TEST, PREVIEW }

///[WeChatScene.SESSION]会话
///[WeChatScene.TIMELINE]朋友圈
///[WeChatScene.FAVORITE]收藏

///LANUCH
enum WeChatScene { SESSION, TIMELINE, FAVORITE,LANUCH }


///[NotifySuperOption.SHARE]分享
///[NotifySuperOption.TOKENEXPIRE]token过期
enum NotifySuperOption { SHARE, TOKENEXPIRE,REFRSH }

extension MiniProgramTypeExtensions on WXMiniProgramType {
  int toNativeInt() {
    switch (this) {
      case WXMiniProgramType.PREVIEW:
        return 2;
      case WXMiniProgramType.TEST:
        return 1;
      case WXMiniProgramType.RELEASE:
        return 0;
    }
    return 0;
  }
}

class EnumUtils {
  ///枚举类型转string
  static String enumToString(o) => o.toString().split('.').last;

  ///string转枚举类型
  static T enumFromString<T>(Iterable<T> values, String value) {
    return values.firstWhere((type) => type.toString().split('.').last == value,
        orElse: () => null);
  }
}
